home *** CD-ROM | disk | FTP | other *** search
/ PC Media 2 / PC MEDIA CD02.iso / share / prog / optasm / ceh.asm next >
Encoding:
Assembly Source File  |  1993-06-09  |  1.6 KB  |  59 lines

  1. ;CEH.ASM -- DOS Critical Error Handler for use with
  2. ;           Microsoft QB 4.x, PDS 7.x & VB/DOS 1.x.
  3.  
  4. .Model Medium, Basic
  5.  
  6. .Data
  7. ErrCode   DW   ?              ;Critical error code
  8. OldInt24  DW   ?,?            ;Original int vector
  9.  
  10. .Code
  11. Proc InstallCEH Uses DS ES
  12.  
  13.      Push SS                  ;Make sure DS points
  14.      Pop  DS                  ;to DGROUP
  15.      Mov  ErrCode, 0FFFFh     ;Initialize ErrCode
  16.     
  17.      Mov  AX, 3524h
  18.      Int  21h                 ;Get original vector
  19.      Mov  OldInt24, BX        ;Save it in OldInt24
  20.      Mov  OldInt24[2], ES
  21.  
  22.      Mov  AX, Seg CEH         ;Point int vector
  23.      Mov  DS, AX              ;to our CEH routine
  24.      Mov  DX, Offset CEH
  25.      Mov  AX, 2524h
  26.      Int  21h
  27.      Ret
  28.     
  29. InstallCEH Endp
  30. Proc RemoveCEH Uses DS
  31.  
  32.      Lds  DX, DWord Ptr OldInt24
  33.      Mov  AX, 2524h           ;Restore original
  34.      Int  21h                 ;int 24h vector
  35.      Ret                      ;and exit
  36.     
  37. RemoveCEH Endp
  38. Proc CEHError
  39.  
  40.      Mov  AX, ErrCode         ;Return value of ErrCode
  41.      Ret                      ;to calling program
  42.  
  43. CEHError Endp
  44. CEH Proc Far
  45.  
  46.      Push SS                  ;Make sure DS points
  47.      Pop  DS                  ;to DGROUP
  48.      Sti                      ;Enable interrupts
  49.      Mov  AX, DI              ;Put DI into AX
  50.      Xor  AH, AH              ;Clear high byte
  51.      Mov  ErrCode, AX         ;and save low byte in ErrCode
  52.      Xor  AL, AL              ;Tell DOS to ignore error
  53.      Stc                      ;Set carry flag
  54.      IRet                     ;and return
  55.  
  56. CEH Endp
  57. End
  58.  
  59.